${rootData.put('pageTitle','跳转中...')}
${rootData.put('navIndex',7)}
<script type="application/javascript">
    //
    var loginSuccess = false;
    $(function () {
        doSubmit();
    });
    function doSubmit() {
        // .超时提示.
        window.setTimeout(function () {
            if (loginSuccess)
                return;
            $("#messageBody").html("好长时间了,我还在努力的认证中...");
            window.setTimeout(function () {
                if (loginSuccess)
                    return;
                $("#messageBody").html("认证中...<br/>建议您换成账号方式登录。如果您坚持,那么请稍等,我还在努力的尝试认证...");
                window.setTimeout(function () {
                    if (loginSuccess)
                        return;
                    jumpTo("/account/login.htm", "抱歉的通知您,20秒过去了。恐怕恐怕是不会成功了,建议您通过帐号方式登录。");
                }, 20000);
            }, 10000);
        }, 5000);
        //
        // .登录表单(后台执行登录)
        var formData = {
            type: "${loginForm.type?html}",
            provider: "${loginForm.provider?html}",
            code: "${loginForm.code?html}",
            redirectURI: "${loginForm.redirectURI?html}",
            csrfToken: "${csrfToken}"
        };
        $.ajax({
            beforeSend: function (request) {
                request.setRequestHeader("ajaxTo", "true");
            },
            url: "${ctx_path}/account/access_token.do",
            data: formData,
            dataType: 'json',
            async: true,
            success: function (result) {
                if (result.success == true) {
                    loginSuccess = true;
                    jumpTo(result.result, "登陆成功,正在为您跳转...");
                } else {
                    jumpTo("/error.htm?errorCode=" + result.errorCode, result.errorMessage);
                }
            },
            error: function (result) {
                jumpTo("/error.htm?errorKey=BAD_REQUEST", result);
            }
        });
    }
    function jumpTo(jumpToURL, message) {
        $("#messageBody").html(message);
        window.setTimeout(function () {
            window.location = jumpToURL;
        }, 1500);
    }
</script>
<div id="messageBody">认证中...</div>